{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>在线测试考核项</legend>
    </fieldset>

    <form class="layui-form layui-form-pane" lay-filter="form" id="form">

        {if $info.type==1}
        <div>
            <div class="layui-form-item">
                <div class="layui-input-6">
                    <textarea readonly="readonly" cols="200" rows="2" style="margin-left: -67px;margin-top: 13px;padding-left: 9px;border: none;font-size: 16px;">
                         考核项题目:&nbsp;&nbsp;&nbsp;{$info.title}
                    </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="margin-left: 60px">
                    {volist name="info.var_content" id="vo"}
                         <span>
                             <span>
                                  <input name="zhi[{$key}]" value="0" hidden>
                                  <input type="checkbox" lay-filter="ck" lay-skin="primary"  name="zhi[{$key}]" value="1">
                             </span>
                             <span>{$vo}</span>
                             <span style="margin-left: 30px;"></span>
                         </span>
                    {/volist}
                </div>
            </div>
        </div>
        {/if}

        {if $info.type==2}
            <div>
                <div class="layui-form-item">
                    <div class="layui-input-6">
                    <textarea readonly="readonly" cols="200" rows="2" style="margin-left: -67px;margin-top: 13px;padding-left: 9px;border: none;font-size: 16px;">
                        考核项题目:&nbsp;&nbsp;&nbsp;{$info.title}
                    </textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block" style="margin-left: 60px;">
                        <span>
                            {volist name="info.var_content" id="vo"}
                            <span>
                                 {$vo}:
                                 <input type="text"  lay-skin="primary" style="width: 30px; height: 20px;" name="zhi[]">
                                 <span style="margin-left: 30px;"></span>
                            </span>
                            {/volist}
                        </span>
                    </div>
                </div>
            </div>
        {/if}
    </form>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" onclick="online_test('{$info.title_id}')">测试</button>
            <a href="{:url('lists')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
        </div>
    </div>
</div>
{include file="common/foot"/}

<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.jquery;
    });

    //在线测试
    function online_test(title_id) {
        $.ajax({
            type: 'POST',
            url: "{:url('online_test')}?title_id="+title_id,
            data: $("#form").serialize(),
            success: function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1});
                }else{
                    layer.msg(res.msg,{icon:2});
                }
            },
            dataType: 'json'
        });

    }

</script>